//
//  PushViewController.m
//  06-UINavigationController
//
//  Created by 李昊林 on 16/7/21.
//  Copyright © 2016年 李昊林. All rights reserved.
//

#import "PushViewController.h"

@interface PushViewController ()

@end

@implementation PushViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    UIButton * backButton = [UIButton buttonWithType:UIButtonTypeSystem];
    backButton.backgroundColor = [UIColor yellowColor];
    backButton.frame = CGRectMake(100, 100, 100, 100);
    [self.view addSubview:backButton];
    [backButton addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)backAction: (UIButton *)button {
    //出栈，返回上一级视图控制器
    [self.navigationController popToRootViewControllerAnimated:YES];
    //返回占中指定的试图控制器
    //[self.navigationController popToViewController:<#(nonnull UIViewController *)#> animated:<#(BOOL)#>]
    
    [self.navigationController pushViewController:[[PushViewController alloc] init] animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
